Add some more GdkEvent getters
authorMatthias Clasen <mclasen@redhat.com>
Mon, 28 Aug 2017 22:47:35 +0000 (18:47 -0400)
committerCarlos Garnacho <carlosg@gnome.org>
Tue, 19 Sep 2017 16:39:03 +0000 (18:39 +0200)
gdk/gdkevents.c
gdk/gdkevents.h

index 72c2cbba8d4aba3d8f9c60a0547a4f26eb5ec721..ce5f7c6248e17675c528e8e90aa9b8c0930c2f02 100644 (file)
@@ -3061,3 +3061,36 @@ gdk_event_set_selection (GdkEvent  *event,
   event->selection.selection = selection;
   event->selection.time = time;
 }
+
+gboolean
+gdk_event_get_axes (GdkEvent  *event,
+                    gdouble  **axes,
+                    guint     *n_axes)
+{
+  GdkDevice *source_device;
+
+  if (!event)
+    return FALSE;
+
+  source_device = gdk_event_get_source_device (event);
+
+  if (!source_device)
+    return FALSE;
+
+  if (event->type == GDK_MOTION_NOTIFY)
+    {
+      *axes = event->motion.axes;
+      *n_axes = gdk_device_get_n_axes (source_device);
+      return TRUE;
+    }
+  else if (event->type == GDK_BUTTON_PRESS ||
+           event->type == GDK_BUTTON_RELEASE)
+    {
+      *axes = event->button.axes;
+      *n_axes = gdk_device_get_n_axes (source_device);
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
index fc158f791dfc13fe79848fff3cf40c3d7a905eb1..320ede61a2bd3dcada872a0cc6afb058ad94f31b 100644 (file)
@@ -819,8 +819,10 @@ void           gdk_event_set_selection (GdkEvent  *event,
                                         GdkWindow *window,
                                         GdkAtom    selection,
                                         guint32    time);
-
-
+GDK_AVAILABLE_IN_3_92
+gboolean       gdk_event_get_axes      (GdkEvent  *event,
+                                        gdouble  **axes,
+                                        guint     *n_axes);
 
 G_END_DECLS